package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.product.client.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022-12-03 1:47
 */
@Controller
@SuppressWarnings("all")
public class CartController {

    @Autowired
    private ProductFeignClient productFeignClient;

    /**
     * 跳转到添加购物车详情信息展示页面
     * @param skuId
     * @param skuNum
     * @return
     */
    @GetMapping("/addCart.html")
    public String addCart(Long skuId, Integer skuNum, Model model) {
        // 远程调用获取获取skuInfo
        SkuInfo skuInfo = productFeignClient.getSkuInfo(skuId);
        model.addAttribute("skuInfo", skuInfo);
        model.addAttribute("skuNum", skuNum);
        return "cart/addCart";
    }



    /**
     * 跳转到我的购物车页面
     * @return
     */
    @GetMapping("/cart.html")
    public String cart() {
        return "cart/index";
    }
}
